package cn.yeyiu.netonlinevideo.fragment;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.LinearLayoutCompat;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;
import java.util.Map;

import cn.yeyiu.netonlinevideo.R;
import cn.yeyiu.util.bean.MediaData;

public abstract class DataFragment extends Fragment {

    protected final Context mContext;

    protected RecyclerView rv;
    protected View loading;

    public DataFragment(Context context) {
        mContext = context;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View root = LayoutInflater.from(mContext).inflate(R.layout.fragment_list_data, container, true);

        rv = root.findViewById(R.id.fragment_rv);
        loading = root.findViewById(R.id.fragment_loading);

        return root;
    }

    public final void changing() {
        if (loading != null) {
            loading.setVisibility(View.VISIBLE);
        }
    }

    public final void changed() {
        if (loading != null) {
            loading.setVisibility(View.GONE);
            rv.scrollToPosition(0);
        }
    }

    public abstract void infoDataChange(List<MediaData> mediaDataList);
}
